# python do_test_point.py
import os


from test_worker_main import start_working

NUM_OF_SUB_WORKER = 5
SUB_WORKER_NAME = "test_sub_worker_plus"
WORKER_WORKING_DIR = "worker_working_dir"


if __name__ == "__main__":
    test_point_name = "test_point1"
    print("{:*^66}".format(f" {test_point_name}测试开始 "))
    worker_path_list = list(f"./{WORKER_WORKING_DIR}/{SUB_WORKER_NAME}{i}" for i in range(NUM_OF_SUB_WORKER))
    # 编译 test_sub_worker_plus 生成所有 worker
    for i in worker_path_list:
        os.system(f"gcc -o {i} {SUB_WORKER_NAME}.c")
    # 以指定策略启动 eBPF_Access_Control
    print("请在另一个终端用如下面的命令启动 eBPF_Access_Control")
    # sudo python3 start_ac_by_polict_file.py ./Black_box_Testing/test_point1/policy.txt
    print(f"sudo python3 start_ac_by_polict_file.py ./Black_box_Testing/{test_point_name}/policy.txt")
    input("启动 eBPF_Access_Control 后请输入任意内容开始测试")
    # 开始工作
    worker_name_list = list(f"./{SUB_WORKER_NAME}{i}" for i in range(NUM_OF_SUB_WORKER))
    start_working(f"./{test_point_name}/action_plan.txt", worker_name_list, "./worker_working_dir")
    print("{:*^66}".format(f" {test_point_name}测试结束 "))

